<?php

class Application_Model_Circuit
{
	protected $_cirNum;
	protected $_pays;
	protected $_cirNom;
	protected $_cirLongueur;
	protected $_cirNbSpectateurs;
	protected $_cirAdresseImage;
	protected $_cirText;

	public function __construct(array $options = null)
	{
		if(is_array($options))
		{
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value)
	{
		$method = 'set' . $name;
		if(('mapper' == $name) || !method_exists($this, $method))
		{
			throw new Exception('Invalid circuit property');
		}
		$this->$method($value);
	}
	public function __get($name)
	{
		$method = 'get' . $name;
		if(('mapper' == $name) || !method_exists($this, $method))
		{
			throw new Exception('Invalid circuit property');
		}
		return $this->$method();
	}

	public function setOptions(array $options)
	{
		$methods = get_class_methods($this);
		foreach ($options as $key => $value)
		{
			$method = 'set' . ucfirst($key);
			if(in_array($method, $methods))
			{
				$this->$method($value);
			}
		}
		return $this;
    }
	
    public function setCirNum($cirNum)
	{
		$this->_cirNum = (int)$cirNum;
		return $this;
	}
	public function getCirNum()
	{
		return $this->_cirNum;
	}
    
	public function setPays($pays)
	{
		$this->_pays = $pays;
		return $this;
	}
	public function getPays()
	{
		return $this->_pays;
	}
	
	public function setCirNom($cirNom)
	{
		$this->_cirNom = (string)$cirNom;
		return $this;
	}
	public function getCirNom()
	{
		return $this->_cirNom;
	}

	public function setCirLongueur($cirLongueur)
	{
		$this->_cirLongueur = (int)$cirLongueur;
		return $this;
	}
	public function getCirLongueur()
	{
		return $this->_cirLongueur;
	}

	public function setCirNbSpectateurs($cirNbSpectateurs)
	{
		$this->_cirNbSpectateurs = (int)$cirNbSpectateurs;
		return $this;
	}
	public function getCirNbSpectateurs()
	{
		return $this->_cirNbSpectateurs;
	}

	public function setCirAdresseImage($cirAdresseImage)
	{
		$this->_cirAdresseImage = (string)$cirAdresseImage;
		return $this;
	}
	public function getCirAdresseImage()
	{
		return $this->_cirAdresseImage;
	}
	
	public function setCirText($cirText)
	{
		$this->_cirText = (string)$cirText;
		return $this;
	}
	public function getCirText()
	{
		return $this->_cirText;
	}
	
	public function toArray()
	{
		$tab = array();
		$tab['cirnum']=$this->_cirNum;
		if(!is_null($this->_pays))
		{
			$tab['paynum']=$this->_pays->getPayNum();
		}
		$tab['cirnom']=$this->_cirNom;
		$tab['cirlongueur']=$this->_cirLongueur;
		$tab['cirnbspectateurs']=$this->_cirNbSpectateurs;
		$tab['ciradresseimage']=$this->_cirAdresseImage;
		$tab['cirtext']=$this->_cirText;
		
		return $tab;
	}
}